import { QRData } from '../qrcode/QRData';
import { Mode } from '../qrcode/Mode';
import { BitBuffer } from '../qrcode/BitBuffer';
import { stringToBytes_UTF8 } from '../text/stringToBytes_UTF8';
/**
 * QR8BitByte
 * @author Kazuhiko Arase
 */
export class QR8BitByte extends QRData {

  constructor(data: string) {
    super(Mode.MODE_8BIT_BYTE, data);
  }

  public write(buffer: BitBuffer): void {
    var data = stringToBytes_UTF8(this.getData());
    for (var i = 0; i < data.length; i += 1) {
      buffer.put(data[i], 8);
    }
  }

  public getLength(): number {
    return stringToBytes_UTF8(this.getData()).length;
  }
}
